import time

from monitor.log_schedule_handler import loggers
from monitor.redis_pool import OPRedis

app_log = loggers


def wincc_task(key, *args):
    loggers.info({"type": "wincc_task_start."})
    start_time = time.time()
    try:
        conn = OPRedis()
        conn.set_list_value(key, *args)
        conn.del_list_value(key, 0, 2)
        res = conn.get_list_value(key, 0, -1)
        print(res)

    except Exception as e:
        loggers.error({"type": "wincc_task", "msg": str(e)})
    finally:
        end_time = time.time()
        loggers.info({"type": "wincc_task_end.", "exec_time": end_time - start_time})
